home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / mcu11 / gloadd3b.arc / GLOADD3.BAS < prev    next >
BASIC Source File  |  1991-08-13  |  41KB  |  1,282 lines

  1. '*****************************************************************************
  2. '****************                                             ****************
  3. '****************              D3 Gang Programmer             ****************
  4. '****************                                             ****************
  5. '*****************************************************************************
  6. '*                                                                           *
  7. '* Program Name: GLOADD3.BAS                                                 *
  8. '* Revision: 0.02                                                            *
  9. '* Date: 4/11/90                                                             *
  10. '* Written By: Robert Chretien                                               *
  11. '*             Motorola MCU Applications                                     *
  12. '* Compiled Under: Microsoft QuickBASIC Version 4.00                         *
  13. '*                                                                           *
  14. '* Program Description:                                                      *
  15. '*                                                                           *
  16. '*                                                                           *
  17. '*                                                                           *
  18. '*                                                                           *
  19. '*                                                                           *
  20. '*****************************************************************************
  21. '*                                                                           *
  22. '* Revision Descriptions:                                                    *
  23. '* 1. Rev 0.00: Original program.                                            *
  24. '* 2. Rev 0.01: Added header and comments.                                   *
  25. '*              Added code allowing choice of COM ports, and variable loop   *
  26. '*              timing (time until BASIC program decides HC11 is not going   *
  27. '*              to respond) based on type and speed of machine.              *
  28. '*              Configuration is stored to disk and loaded on start-up.      *
  29. '*              Added debug options for checking connection, load test       *
  30. '*              program into RAM and running it, same for EPROM, and option  *
  31. '*              for enabling and disabling debug breaks.                     *
  32. '* 3. Rev 0.02: Corrected spelling and grammer in comments.                  *
  33. '* 4. Rev 0.03: Use different means of determining end of s19 file so that   *
  34. '*              now there is no limit to the size of the file.               *
  35. '*              Modified software handshaking to increase speed of transfer  *
  36. '*              between HC11 and IBM.                                        *
  37. '*              Changed programming delay down to 2ms per spec.              *
  38. '*              Added error checking for user input.                         *
  39. '*              Added routine to compare memory contents to S19 file giving  *
  40. '*              both S-record number, byte and byte postion of errors.       *
  41. '*              Added routines to check S19 records for addresses in proper  *
  42. '*              range for memory in part.                                    *
  43. '*                                                                           *
  44. '*****************************************************************************
  45. '*****************************************************************************
  46. '
  47. '
  48. '
  49. Initialization:
  50.     DIM RAMLoadByte(300)
  51.     DIM GoodBoard(10)
  52.     Debug = 0
  53.     HexConvert$ = "0123456789ABCDEF"
  54.     OPEN "CONFIG.PD3" FOR INPUT AS #1
  55.     INPUT #1, ComPort, ResponseTime
  56.     CLOSE
  57.     ON ERROR GOTO ErrorTrap
  58. PickMainOption:
  59.     CLS
  60.     LOCATE 4, 16
  61.     PRINT "Motorola MC68HC711D3 GangProgramming Software"
  62.     LOCATE 5, 16
  63.     PRINT "                 Version 0.03"
  64.     LOCATE 9, 10
  65.     PRINT "1) EPROM Blank Check"
  66.     LOCATE 10, 10
  67.     PRINT "2) Program and Verify EPROM"
  68.     LOCATE 11, 10
  69.     PRINT "3) Program and Verify multiple sets of boards with same program"
  70.     LOCATE 12, 10
  71.     PRINT "4) Verify EPROM Contents"
  72.     LOCATE 13, 10
  73.     PRINT "5) Test and Debug"
  74.     LOCATE 15, 10
  75.     PRINT "S) For System Configuration"
  76.     LOCATE 16, 10
  77.     PRINT "X) To EXIT program"
  78.     LOCATE 18, 10
  79.     INPUT "Enter number of desired selection"; OptionChoice$
  80.     IF OptionChoice$ = "X" OR OptionChoice$ = "x" THEN GOSUB ThatsAll
  81.     IF OptionChoice$ = "S" OR OptionChoice$ = "s" THEN
  82.        GOSUB Config
  83.        GOTO PickMainOption
  84.     END IF
  85.     OptionChoice = VAL(OptionChoice$)
  86.     NoBoards = 8
  87.     PartType$ = "D3"
  88.     RAMAddressLow$ = "0040": RAMAddressHigh$ = "00FF"
  89.     MSBBootAddress$ = "BF": LSBBootAddress$ = "46"
  90.     EPromAddressLow$ = "F000": EPromAddressHigh$ = "FFFF"
  91.     IF OptionChoice = 0 THEN GOSUB ThatsAll
  92.     IF OptionChoice = 1 THEN GOSUB Check4Blank
  93.     IF OptionChoice = 2 THEN GOSUB ProgProm
  94. Choice3:
  95.     IF OptionChoice = 3 THEN
  96.        IF RepeatFileName$ = "" THEN
  97. RepeatFileName1:
  98.           CLS
  99.           LOCATE 10, 1
  100.           INPUT "Enter file name to program into EPROM"; RepeatFileName$
  101.        END IF
  102.        GOSUB ProgProm
  103.     END IF
  104.     IF OptionChoice = 3 THEN
  105.        PRINT "Change parts and hit ENTER when ready to program again"
  106.        INPUT "Or enter X to return to main menu"; CR$
  107.        IF CR$ = "X" OR CR$ = "x" THEN
  108.           RepeatFileName$ = ""
  109.           GOTO PickMainOption
  110.        END IF
  111.        GOTO Choice3
  112.     END IF
  113.     IF OptionChoice = 4 THEN GOSUB VerProm
  114.     IF OptionChoice = 5 THEN
  115. DeBugChoice:
  116.        CLS
  117.        LOCATE 4, 18
  118.        PRINT "MC68HC711D3 Board Test and Debug"
  119.        LOCATE 8, 10
  120.        PRINT "1) Test PC to D3 board connection."
  121.        LOCATE 9, 10
  122.        PRINT "2) Load Test Program into RAM and Execute"
  123.        LOCATE 10, 10
  124.        PRINT "3) Program EPROM with Test Program and Execute"
  125.        LOCATE 11, 10
  126.        PRINT "4) Compare file to HC11 memory"
  127.        LOCATE 14, 10
  128.        PRINT "X) Return to main menu"
  129.        LOCATE 16, 10
  130.        INPUT "Enter number of desired selection"; DeBugChoice$
  131.        IF DeBugChoice$ = "X" OR DeBugChoice$ = "x" THEN GOTO PickMainOption
  132.        IF DeBugChoice$ = "1" THEN GOSUB CheckConnection
  133.        IF DeBugChoice$ = "2" THEN GOSUB TestWithRAM
  134.        IF DeBugChoice$ = "3" THEN GOSUB TestProgProm
  135.        IF DeBugChoice$ = "4" THEN GOSUB VerProm
  136.        GOTO DeBugChoice
  137.     END IF
  138.     GOTO PickMainOption
  139.  
  140. WhatNext:
  141.        ' download finished. what now?
  142. ThatsAll:
  143.     CLOSE
  144.     END
  145.  
  146.  
  147. '*****************************************************************************
  148. '*****************************************************************************
  149. '*                                                                           *
  150. '*                     First level subroutines                               *
  151. '*                                                                           *
  152. '*****************************************************************************
  153. '*
  154. '*
  155. '*
  156. Config:
  157.     CLS
  158.     LOCATE 3, 10
  159.     PRINT "Configuration Menu"
  160.     LOCATE 6, 5
  161.     PRINT "Enter the number corresponding to the serial port in use."
  162.     LOCATE 8, 5
  163.     PRINT "1) COM1"
  164.     LOCATE 9, 5
  165.     PRINT "2) COM2"
  166.     LOCATE 11, 5
  167.     INPUT "HC711D3 board connected to serial port"; ComPort
  168.     IF ComPort = 0 THEN GOTO Config
  169.     IF ComPort > 2 THEN GOTO Config
  170.     LOCATE 14, 5
  171.     PRINT "Enter the number of the PC description closest to your machine"
  172.     PRINT "       NOTE: If in doubt pick a slower machine"
  173. MachineType:
  174.     LOCATE 16, 5
  175.     PRINT "1) Slow PC/XT (Non-Turbo)"
  176.     LOCATE 17, 5
  177.     PRINT "2) Fast PC/XT (Turbo)"
  178.     LOCATE 18, 5
  179.     PRINT "3) Slow PC/AT/XT-286 (6MHz to 10MHz)"
  180.     LOCATE 19, 5
  181.     PRINT "4) Medium Speed PC/AT/XT-286 (12MHz to 16MHz)"
  182.     LOCATE 20, 5
  183.     PRINT "5) Fast PC/AT/XT-286 (Faster than 16MHz)"
  184.     LOCATE 21, 5
  185.     PRINT "6) 386 Machines"
  186.     LOCATE 23, 5
  187.     INPUT "Machine Type"; Machine
  188.     IF Machine = 0 THEN GOTO MachineType
  189.     IF Machine = 1 THEN ResponseTime = 100
  190.     IF Machine = 2 THEN ResponseTime = 200
  191.     IF Machine = 3 THEN ResponseTime = 400
  192.     IF Machine = 4 THEN ResponseTime = 500
  193.     IF Machine = 5 THEN ResponseTime = 600
  194.     IF Machine = 6 THEN ResponseTime = 800
  195.     IF Machine > 6 THEN GOTO MachineType
  196.     INPUT "Is the above correct"; CR$
  197.     IF CR$ <> "Y" AND CR$ <> "y" THEN GOTO Config
  198.     INPUT "Save configuration to disk"; CR$
  199.     IF CR$ <> "Y" AND CR$ <> "y" THEN GOTO ConfigDone
  200.     OPEN "CONFIG.PD3" FOR OUTPUT AS #1
  201.     PRINT #1, ComPort, ResponseTime
  202.     CLOSE
  203. ConfigDone:
  204.     RETURN
  205. '*
  206. '*
  207. '*
  208. Check4Blank:
  209.     BootLoad = 1: FirstRecordSent = 0: BlankCheck = 1
  210.     CheckSum = 0: Verify = 0: TalkAddress = 8
  211.     Filename$ = "GBlankD3.MX"
  212.     CLS
  213.     LOCATE 1, 1
  214.     PRINT "Downloading code into RAM for blank checking."
  215.     GOSUB CheckFile
  216.     GOSUB ConvertFile4RAM
  217.     GOSUB RAMSendFile
  218.     GOSUB PollAfterBootLoad
  219.     CLS
  220.     PRINT "Board Status:"
  221.     PRINT
  222.     FOR I = 1 TO 8
  223.     PRINT "Board "; I - 1
  224.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  225.     IF GoodBoard(I) = 1 THEN PRINT "Part verified as blank."
  226.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  227.     IF GoodBoard(I) = 3 THEN PRINT "Part NOT blank."
  228.     NEXT I
  229.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  230.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  231.     PRINT #1, CHR$(value);
  232.     CLOSE #1
  233.     PRINT : PRINT
  234.     IF TalkAddress = 8 THEN
  235.        PRINT "No boards are responding."
  236.        PRINT "Reset the HC11."
  237.     END IF
  238.     INPUT "Hit ENTER to continue"; CR$
  239.     RETURN
  240.  
  241. ProgProm:
  242.     FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
  243.     CheckSum = 5: Verify = 0
  244.     Filename$ = "GPROGD3.MX"
  245.     CLS
  246.     LOCATE 1, 1
  247.     PRINT "Downloading code into RAM for PROM programming."
  248.     GOSUB CheckFile
  249.     GOSUB ConvertFile4RAM
  250.     GOSUB RAMSendFile
  251.     GOSUB PollAfterBootLoad
  252.  
  253.     CLS
  254.     PRINT "Board Status:"
  255.     PRINT
  256.     FOR I = 1 TO 8
  257.     PRINT "Board "; I - 1
  258.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  259.     IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
  260.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  261.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
  262.     NEXT I
  263.     BootLoad = 0
  264.     LOCATE 21, 1
  265.     IF TalkAddress = 8 THEN
  266.        PRINT "No boards are responding."
  267.        PRINT "Reset the HC11."
  268.        CLOSE
  269.        INPUT "Hit RETURN to continue."; CR$
  270.        GOTO PickMainOption
  271.     ELSE
  272.        PRINT "RAM ready to program PROM."
  273.        IF OptionChoice = 3 THEN
  274.           Filename$ = RepeatFileName$
  275.           GOTO Option3
  276.        END IF
  277. Filename1:
  278.        LOCATE 23, 1
  279.        PRINT "Or reset the HC11 then enter X to return to the main menu."
  280.        LOCATE 22, 1
  281.        INPUT "Enter file to be downloaded into PROM"; Filename$
  282.        IF Filename$ = "" THEN GOTO Filename1
  283.        IF Filename$ = "X" OR Filename$ = "x" THEN GOTO PickMainOption
  284.     END IF
  285. Option3:
  286.     GOSUB CheckFile
  287.     GOSUB SendFile
  288.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  289.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  290.     PRINT #1, CHR$(value);
  291.     CLOSE #1
  292.     CLS
  293.     PRINT "PROM has been programmed."
  294.     CLOSE #2
  295.     TempFileName$ = Filename$
  296.     GOSUB VerProm
  297.     RETURN
  298.  
  299. VerProm:
  300.     FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
  301.     CheckSum = 5: Verify = 1
  302.     Filename$ = "GVERD3.MX"
  303.     CLS
  304.     LOCATE 1, 1
  305.     PRINT "Downloading code into RAM for PROM verification."
  306.     GOSUB CheckFile
  307.     GOSUB ConvertFile4RAM
  308.     GOSUB RAMSendFile
  309.     GOSUB PollAfterBootLoad
  310.  
  311.     CLS
  312.     PRINT "Board Status:"
  313.     PRINT
  314.     FOR I = 1 TO 8
  315.     PRINT "Board "; I - 1
  316.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  317.     IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
  318.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  319.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
  320.     NEXT I
  321.     BootLoad = 0
  322.     IF OptionChoice = 2 OR OptionChoice = 3 OR DeBugChoice$ = "3" THEN
  323.        Filename$ = TempFileName$
  324.     ELSE
  325.        IF TalkAddress = 8 THEN
  326.           LOCATE 22, 1
  327.           PRINT "No boards are responding."
  328.           PRINT "Reset the HC11"
  329.           CLOSE
  330.           INPUT "Hit RETURN to continue."; CR$
  331.           GOTO PickMainOption
  332.        END IF
  333. Filename2:
  334.        LOCATE 23, 1
  335.        PRINT "Or reset the HC11 then enter X to return to the main menu."
  336.        LOCATE 22, 1
  337.        INPUT "Enter file to be verified against PROM"; Filename$
  338.        IF Filename$ = "" THEN GOTO Filename2
  339.        IF Filename$ = "X" OR Filename$ = "x" THEN GOTO PickMainOption
  340.        IF DeBugChoice$ = "4" THEN
  341.           GOSUB CheckFile
  342.           GOSUB CompareFile
  343.           GOTO Verf
  344.        END IF
  345.     END IF
  346.     GOSUB CheckFile
  347.     GOSUB SendFile
  348. Verf:
  349.     VerifyFirstOnly = 0: SentValue = 0: CheckSum = 0
  350.     CLS
  351.     LOCATE 1, 1
  352.     PRINT "Polling boards for verification."
  353.     CLOSE
  354.     GOSUB PollAfterBootLoad
  355.     CLS
  356.     PRINT "Board Status:"
  357.     PRINT
  358.     FOR I = 1 TO 8
  359.     PRINT "Board "; I - 1
  360.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  361.     IF GoodBoard(I) = 1 THEN PRINT "Part verified correctly."
  362.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  363.     IF GoodBoard(I) = 3 THEN PRINT "Part does NOT verify."
  364.     NEXT I
  365.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  366.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  367.     PRINT #1, CHR$(value);
  368.     CLOSE #1
  369.     PRINT : PRINT
  370.     INPUT "Hit ENTER to continue"; CR$
  371.     RETURN
  372.  
  373. CheckConnection:
  374.     BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
  375.     CheckSum = 0: Verify = 0
  376.     Filename$ = "GConD3.MX"
  377.     CLS
  378.     LOCATE 1, 1
  379.     PRINT "Downloading code into RAM to check connection."
  380.     GOSUB CheckFile
  381.     GOSUB ConvertFile4RAM
  382.     GOSUB RAMSendFile
  383.     GOSUB PollAfterBootLoad
  384.     CLS
  385.     PRINT "Board Status:"
  386.     PRINT
  387.     FOR I = 1 TO 8
  388.     PRINT "Board "; I - 1
  389.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  390.     IF GoodBoard(I) = 1 THEN PRINT "Board connection verified."
  391.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding correctly."
  392.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding correctly."
  393.     NEXT I
  394.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  395.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  396.     PRINT #1, CHR$(value);
  397.     CLOSE #1
  398.     PRINT : PRINT
  399.     INPUT "Hit ENTER to continue"; CR$
  400.     RETURN
  401.  
  402. TestWithRAM:
  403.     BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
  404.     CheckSum = 0: Verify = 0
  405.     Filename$ = "LEDD3.MX"
  406.     CLS
  407.     LOCATE 1, 1
  408.     PRINT "Downloading code into RAM for Board Test."
  409.     GOSUB CheckFile
  410.     GOSUB ConvertFile4RAM
  411.     GOSUB RAMSendFile
  412.     CLS
  413.     PRINT "Red LED Should blink 16 times."
  414.     INPUT "Hit RETURN when complete."; CR$
  415.     RETURN
  416.  
  417. TestProgProm:
  418.     FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
  419.     CheckSum = 5: Verify = 0
  420.     Filename$ = "GPROGD3.MX"
  421.     CLS
  422.     LOCATE 1, 1
  423.     PRINT "Downloading code into RAM for PROM programming."
  424.     GOSUB CheckFile
  425.     GOSUB ConvertFile4RAM
  426.     GOSUB RAMSendFile
  427.     GOSUB PollAfterBootLoad
  428.  
  429.     CLS
  430.     PRINT "Board Status:"
  431.     PRINT
  432.     FOR I = 1 TO 8
  433.     PRINT "Board "; I - 1
  434.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  435.     IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
  436.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
  437.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
  438.     NEXT I
  439.     BootLoad = 0
  440.     LOCATE 21, 1
  441.     PRINT "RAM ready to program PROM."
  442.     Filename$ = "D3Blink.MX"
  443.     GOSUB CheckFile
  444.     GOSUB SendFile
  445.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  446.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  447.     PRINT #1, CHR$(value);
  448.     CLOSE #1
  449.     CLS
  450.     CLOSE #2
  451.     TempFileName$ = Filename$
  452.     GOSUB VerProm
  453.  
  454.     BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
  455.     CheckSum = 0: Verify = 0
  456.     Filename$ = "GJMPD3.MX"
  457.     CLS
  458.     LOCATE 1, 1
  459.     PRINT "Downloading code into RAM to jump to EPROM."
  460.     GOSUB CheckFile
  461.     GOSUB ConvertFile4RAM
  462.     GOSUB RAMSendFile
  463.     GOSUB PollAfterBootLoad
  464.     CLS
  465.     PRINT "Board Status:"
  466.     PRINT
  467.     FOR I = 1 TO 8
  468.     PRINT "Board "; I - 1
  469.     IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
  470.     IF GoodBoard(I) = 1 THEN PRINT "Board connection verified."
  471.     IF GoodBoard(I) = 2 THEN PRINT "Board not responding correctly."
  472.     IF GoodBoard(I) = 3 THEN PRINT "Board not responding correctly."
  473.     NEXT I
  474.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  475.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  476.     PRINT #1, CHR$(value);
  477.     CLOSE #1
  478.  
  479.     PRINT
  480.     PRINT "PROM has been programmed."
  481.     PRINT "The LED's should blink 16 times."
  482.     INPUT "Hit RETURN when finished"; CR$
  483.     RETURN
  484.  
  485.  
  486. '*****************************************************************************
  487. '*****************************************************************************
  488. '*                                                                           *
  489. '*                      Level two  subroutines                               *
  490. '*                                                                           *
  491. '*****************************************************************************
  492. '*****************************************************************************
  493.  
  494. '*****************************************************************************
  495. '*                                                                           *
  496. '*        This routine checks for non S-records in files                     *
  497. '*                                                                           *
  498. '*****************************************************************************
  499.  
  500. CheckFile:
  501.     CLS
  502.     LOCATE 10, 10
  503.     PRINT "Checking the S19 file for validity and address ranges."
  504.     RecordCount = 0
  505.     RAMAddressLow = 64: RAMAddressHigh = 255
  506.     EPromAddressLow = 61440: EPromAddressHigh = 65535
  507.     OPEN Filename$ FOR INPUT AS #2
  508. NoS1Records:
  509.     INPUT #2, record$
  510.     IF LEFT$(record$, 2) = "S0" THEN GOTO NoS1Records
  511.     IF LEFT$(record$, 2) = "S1" THEN
  512.         RecordCount = RecordCount + 1
  513.         Nibble$ = MID$(record$, 3, 1)
  514.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  515.         IF Nibble = -1 THEN
  516.            CLS
  517.            PRINT "Error converting number1 to hex."
  518.            PRINT "Reset the HC11."
  519.            CLOSE
  520.            INPUT "Hit RETURN to continue."; CR$
  521.            RETURN PickMainOption
  522.            END IF
  523.         CheckLength = Nibble * 16
  524.         Nibble$ = MID$(record$, 4, 1)
  525.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  526.         IF Nibble = -1 THEN
  527.            CLS
  528.            PRINT "Error converting number2 to hex."
  529.            PRINT "Reset the HC11."
  530.            CLOSE
  531.            INPUT "Hit RETURN to continue."; CR$
  532.            RETURN PickMainOption
  533.            END IF
  534.         CheckLength = (CheckLength + Nibble) - 4
  535.  
  536.         CheckAddress$ = MID$(record$, 5, 4)
  537.         Nibble$ = LEFT$(CheckAddress$, 1)
  538.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  539.         IF Nibble = -1 THEN
  540.            CLS
  541.            PRINT "Error converting number1 to hex."
  542.            PRINT "Reset the HC11."
  543.            CLOSE
  544.            INPUT "Hit RETURN to continue."; CR$
  545.            RETURN PickMainOption
  546.         END IF
  547.         CheckAddress = Nibble * 4096
  548.         Nibble$ = MID$(CheckAddress$, 2, 1)
  549.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  550.         IF Nibble = -1 THEN
  551.            CLS
  552.            PRINT "Error converting number2 to hex."
  553.            PRINT "Reset the HC11."
  554.            CLOSE
  555.            INPUT "Hit RETURN to continue."; CR$
  556.            RETURN PickMainOption
  557.            END IF
  558.         CheckAddress = CheckAddress + (Nibble * 256)
  559.         Nibble$ = MID$(CheckAddress$, 3, 1)
  560.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  561.         IF Nibble = -1 THEN
  562.            CLS
  563.            PRINT "Error converting number3 to hex."
  564.            PRINT "Reset the HC11."
  565.            CLOSE
  566.            INPUT "Hit RETURN to continue."; CR$
  567.            RETURN PickMainOption
  568.            END IF
  569.         CheckAddress = CheckAddress + (Nibble * 16)
  570.         Nibble$ = RIGHT$(CheckAddress$, 1)
  571.         Nibble = INSTR(HexConvert$, Nibble$) - 1
  572.         IF Nibble = -1 THEN
  573.            CLS
  574.            PRINT "Error converting number4 to hex."
  575.            PRINT "Reset the HC11."
  576.            CLOSE
  577.            INPUT "Hit RETURN to continue."; CR$
  578.            RETURN PickMainOption
  579.            END IF
  580.         CheckAddress = CheckAddress + Nibble
  581.         IF BootLoad = 1 THEN
  582.            IF CheckAddress < RAMAddressLow THEN GOTO AddressError
  583.            IF CheckAddress + CheckLength > RAMAddressHigh THEN GOTO AddressError
  584.            GOTO NoS1Records
  585.         END IF
  586.         IF CheckAddress < EPromAddressLow THEN GOTO AddressError
  587.         IF CheckAddress + CheckLength > EPromAddressHigh THEN GOTO AddressError
  588.         GOTO NoS1Records
  589.     END IF
  590.     IF LEFT$(record$, 2) = "S9" THEN
  591.        IF RecordCount = 0 THEN
  592.           CLOSE
  593.           CLS
  594.           LOCATE 12, 1
  595.           PRINT "There are no S1 records in this file."
  596.           INPUT "Hit enter to continue"; CR$
  597.           RETURN PickMainOption
  598.        ELSE
  599.           CLOSE #2
  600.           RETURN
  601.        END IF
  602.     END IF
  603.     CLOSE
  604.     CLS
  605.     LOCATE 12, 1
  606.     PRINT "This file contains one or more none S19 records."
  607.     INPUT "Hit enter to continue"; CR$
  608.     RETURN PickMainOption
  609.  
  610. AddressError:
  611.     CLS
  612.     CLOSE
  613.     PRINT "S-record file contains address not available in this part."
  614.     PRINT "File name: "; Filename$
  615.     PRINT "Record Number "; RecordCount
  616.     PRINT "Record = "; record$
  617.     PRINT "Record start address: $"; HEX$(CheckAddress)
  618.     PRINT "Record end address: $"; HEX$(CheckAddress + CheckLength)
  619.     PRINT
  620.     PRINT "Reset the HC11."
  621.     INPUT "Hit RETURN to continue."; CR$
  622.     RETURN PickMainOption
  623.  
  624.  
  625.  
  626. '*****************************************************************************
  627. '*                                                                           *
  628. '*    Convert from S-records for fast download to RAM using Bootloader       *
  629. '*                                                                           *
  630. '*                                                                           *
  631. '*****************************************************************************
  632. ConvertFile4RAM:
  633.     RAMLoadByte$ = CHR$(255)
  634.     RecordCount = 0
  635.     OPEN Filename$ FOR INPUT AS #2
  636. RAMNoS1Records:
  637.     INPUT #2, record$
  638.     IF LEFT$(record$, 2) = "S0" THEN GOTO RAMNoS1Records
  639.     IF LEFT$(record$, 2) = "S1" THEN
  640.        record$ = RIGHT$(record$, LEN(record$) - 6)
  641.        RecordCount = RecordCount + 1
  642. NextConvertByte:
  643.        record$ = RIGHT$(record$, LEN(record$) - 2)
  644.        IF LEN(record$) > 2 THEN
  645.           ConvertByte$ = LEFT$(record$, 2)
  646.           Nibble$ = LEFT$(ConvertByte$, 1)
  647.           Nibble = INSTR(HexConvert$, Nibble$) - 1
  648.           IF Nibble = -1 THEN
  649.          CLS
  650.          PRINT "Error converting number1 to hex"
  651.          INPUT CR$
  652.          RETURN
  653.           END IF
  654.           MSBNibble = Nibble * 16
  655.           Nibble$ = RIGHT$(ConvertByte$, 1)
  656.           Nibble = INSTR(HexConvert$, Nibble$) - 1
  657.           IF Nibble = -1 THEN
  658.          CLS
  659.          PRINT "Error converting number1 to hex"
  660.          INPUT CR$
  661.          RETURN
  662.           END IF
  663.           value = MSBNibble + Nibble
  664.           RAMLoadByte$ = RAMLoadByte$ + CHR$(value)
  665.           GOTO NextConvertByte
  666.         END IF
  667.         GOTO RAMNoS1Records
  668.     END IF
  669.     IF LEFT$(record$, 2) = "S9" THEN
  670.        IF RecordCount = 0 THEN
  671.           CLOSE
  672.           CLS
  673.           LOCATE 12, 1
  674.           PRINT "There are no S1 records in this file."
  675.           INPUT "Hit enter to continue"; CR$
  676.           RETURN PickMainOption
  677.        ELSE
  678.           CLOSE
  679.           CLS
  680.           RETURN
  681.        END IF
  682.     END IF
  683.     CLOSE
  684.     CLS
  685.     LOCATE 12, 1
  686.     PRINT "This file contains one or more none S19 records."
  687.     INPUT "Hit enter to continue"; CR$
  688.     RETURN PickMainOption
  689.  
  690. '*****************************************************************************
  691. '*                                                                           *
  692. '*              This routine programs RAM using bootloader                   *
  693. '*                                                                           *
  694. '*****************************************************************************
  695.  
  696. RAMSendFile:
  697.        LOCATE 4, 1
  698.        PRINT "Transfering control program to HC11 RAM."
  699.  
  700.     I = 0
  701.     IF ComPort = 1 THEN OPEN "COM1:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  702.     IF ComPort = 2 THEN OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  703.     PRINT #1, RAMLoadByte$;
  704.     CLOSE
  705.     RETURN
  706.  
  707.  
  708. '*****************************************************************************
  709. '*                                                                           *
  710. '*              This routine sends file to HC11                              *
  711. '*                                                                           *
  712. '*****************************************************************************
  713.  
  714. SendFile:
  715.     OPEN Filename$ FOR INPUT AS #2
  716.     IF BootLoad = 1 THEN
  717.        IF ComPort = 1 THEN OPEN "COM1:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  718.        IF ComPort = 2 THEN OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  719.        value = 255
  720.        PRINT #1, CHR$(value);
  721.     END IF
  722.     IF BootLoad = 0 THEN
  723.        IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  724.        IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  725.     END IF
  726.     BytesSent = 0
  727.     RecordsSent = 0
  728.     CLS
  729.     LOCATE 10, 10
  730.     PRINT "Number of records to be sent: "; RecordCount
  731.     LOCATE 11, 10
  732.     PRINT "Records sent: "
  733. SendFileLength:
  734.        IF BootLoad = 0 THEN
  735.           TransErrorCode = 0
  736.           value = TalkAddress
  737.           GOSUB TRANSxVALUE
  738.           VerifyFirstOnly = 1
  739.           SentValue = value
  740.           GOSUB CheckRecValue
  741.           IF TransErrorCode <> 1 THEN
  742.          LOCATE 20, 1
  743.          PRINT "Verification of talk address failed."
  744.          PRINT "Reset the HC11."
  745.          CLOSE
  746.          INPUT "Hit RETURN to continue."; CR$
  747.          RETURN PickMainOption
  748.           END IF
  749.        END IF
  750. GetRecord:
  751.     INPUT #2, record$
  752.     RecordType$ = LEFT$(record$, 2)
  753.     IF RecordType$ = "S0" THEN
  754.        GOTO GetRecord
  755.     END IF
  756.     IF RecordType$ = "S1" THEN
  757.        RecordsSent = RecordsSent + 1
  758.        LOCATE 11, 24
  759.        PRINT RecordsSent
  760.        RecordLength$ = MID$(record$, 3, 2)
  761.        RecordAddress$ = MID$(record$, 5, 4)
  762.        record$ = RIGHT$(record$, LEN(record$) - 8)
  763. ParseAndSend:
  764.        IF BootLoad = 1 THEN
  765.           TransErrorCode = 0
  766.           IF LEN(record$) > 2 THEN
  767.          TransHexValue$ = LEFT$(record$, 2)
  768.          record$ = RIGHT$(record$, LEN(record$) - 2)
  769.          GOSUB SENDxVALUE
  770.          IF TransErrorCode <> 1 THEN
  771.             LOCATE 20, 1
  772.             PRINT "Verification failed."
  773.             PRINT "Successfully sent "; RecordsSent; " S1 records."
  774.             PRINT "Reset the HC11."
  775.             CLOSE
  776.             INPUT "Hit RETURN to continue."; CR$
  777.             RETURN PickMainOption
  778.          ELSE
  779.             GOTO ParseAndSend
  780.          END IF
  781.           ELSE
  782.          GOTO GetRecord
  783.           END IF
  784.        ELSE
  785. SendAddress:
  786.           TransErrorCode = 0
  787.           TransHexValue$ = LEFT$(RecordAddress$, 2)
  788.           GOSUB SENDxVALUE
  789.           VerifyFirstOnly = 1
  790.           SentValue = value
  791.           GOSUB CheckRecValue
  792.           IF TransErrorCode <> 1 THEN
  793.          LOCATE 20, 1
  794.          PRINT "Verification of MSB of address failed."
  795.          PRINT "Reset the HC11."
  796.          CLOSE
  797.          INPUT "Hit RETURN to continue."; CR$
  798.          RETURN PickMainOption
  799.           END IF
  800.           TransHexValue$ = RIGHT$(RecordAddress$, 2)
  801.           GOSUB SENDxVALUE
  802.           VerifyFirstOnly = 1
  803.           SentValue = value
  804.           GOSUB CheckRecValue
  805.           IF TransErrorCode <> 1 THEN
  806.          LOCATE 20, 1
  807.          PRINT "Verification of LSB of address failed."
  808.          PRINT "Reset the HC11."
  809.          CLOSE
  810.          INPUT "Hit RETURN to continue."; CR$
  811.          RETURN PickMainOption
  812.           END IF
  813. SendRecordLength:
  814.           TransHexValue$ = RecordLength$
  815.           GOSUB SENDxVALUE
  816.           VerifyFirstOnly = 1
  817.           SentValue = value
  818.           GOSUB CheckRecValue
  819.           IF TransErrorCode <> 1 THEN
  820.          LOCATE 20, 1
  821.          PRINT "Verification of record length failed."
  822.          PRINT "Reset the HC11."
  823.          CLOSE
  824.          PRINT "Hit RETURN to continue,"; CR$
  825.          RETURN PickMainOption
  826.           END IF
  827. SendData:
  828.           IF LEN(record$) > 2 THEN
  829.          TransHexValue$ = LEFT$(record$, 2)
  830.          record$ = RIGHT$(record$, LEN(record$) - 2)
  831.          GOSUB SENDxVALUE
  832.          VerifyFirstOnly = 1
  833.          SentValue = value
  834.          GOSUB CheckRecValue
  835.          IF TransErrorCode <> 1 THEN
  836.             LOCATE 20, 1
  837.             PRINT "Verification failed."
  838. '                    PRINT "Successfully sent "; RecordsSent; " S1 records."
  839. '                    INPUT "Reset the HC11 then enter RETURN to go to main menu."; CR$
  840. '                    GOTO PickMainOption
  841.             GOTO SendData
  842.          ELSE
  843.             GOTO SendData
  844.          END IF
  845.           ELSE
  846.          FirstRecordSent = 1
  847.          GOTO GetRecord
  848.           END IF
  849.        END IF
  850.     END IF
  851.     IF RecordType$ = "S9" THEN
  852.        TransErrorCode = 0
  853.        TransHexValue$ = "00"
  854.        GOSUB SENDxVALUE
  855.        VerifyFirstOnly = 1
  856.        SentValue = value
  857.        GOSUB CheckRecValue
  858.        IF TransErrorCode <> 1 THEN
  859.           LOCATE 20, 1
  860.           PRINT "Verification of end of file1 failed."
  861.           PRINT "Reset the HC11."
  862.           CLOSE
  863.           INPUT "Hit RETURN to continue."; CR$
  864.           RETURN PickMainOption
  865.        END IF
  866.        TransErrorCode = 0
  867.        TransHexValue$ = "00"
  868.        GOSUB SENDxVALUE
  869.        VerifyFirstOnly = 1
  870.        SentValue = value
  871.        GOSUB CheckRecValue
  872.        IF TransErrorCode <> 1 THEN
  873.           LOCATE 20, 1
  874.           PRINT "Verification of end of file2 failed."
  875.           PRINT "Reset the HC11."
  876.           CLOSE
  877.           INPUT "Hit RETURN to continue."; CR$
  878.           RETURN PickMainOption
  879.        END IF
  880.        TransErrorCode = 0
  881.        TransHexValue$ = "00"
  882.        GOSUB SENDxVALUE
  883.        VerifyFirstOnly = 1
  884.        SentValue = value
  885.        GOSUB CheckRecValue
  886.        IF TransErrorCode <> 1 THEN
  887.           LOCATE 20, 1
  888.           PRINT "Verification of end of file3 failed."
  889.           PRINT "Reset the HC11."
  890.           CLOSE
  891.           INPUT "Hit RETURN to continue."; CR$
  892.           RETURN PickMainOption
  893.        END IF
  894.        CLOSE #1
  895.        CLOSE #2
  896.        RETURN
  897.     ELSE
  898.        PRINT "A Non S19 record has been encountered. Abort Download."
  899.        RETURN PickMainOption
  900.     END IF
  901.  
  902.  
  903.  
  904. '*****************************************************************************
  905. '*                                                                           *
  906. '*              This routine compares a file to HC11                         *
  907. '*                                                                           *
  908. '*****************************************************************************
  909.  
  910. CompareFile:
  911.     CLS
  912.     LOCATE 1, 30
  913.     PRINT "File Comparison"
  914.     LOCATE 3, 1
  915.     INPUT "Which board to compare"; TalkAddress
  916.     LOCATE 4, 1
  917.     PRINT "File to compare with: "; Filename$
  918.     OPEN Filename$ FOR INPUT AS #2
  919.     IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  920.     IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  921.     BytesSent = 0
  922.     RecordsSent = 0
  923.     LOCATE 5, 1
  924.     PRINT "Number of records to be sent: "; RecordCount
  925.     LOCATE 6, 1
  926.     PRINT "Records sent: "
  927. SendCFileLength:
  928.     TransErrorCode = 0
  929.     value = TalkAddress
  930.     GOSUB TRANSxVALUE
  931.     VerifyFirstOnly = 1
  932.     SentValue = value
  933.     GOSUB CheckRecValue
  934.     IF TransErrorCode <> 1 THEN
  935.        LOCATE 20, 1
  936.        PRINT "Verification of talk address failed."
  937.        PRINT "Reset the HC11."
  938.        CLOSE
  939.        INPUT "Hit RETURN to continue."; CR$
  940.        RETURN PickMainOption
  941.     END IF
  942. GetCRecord:
  943.     INPUT #2, record$
  944.     RecordType$ = LEFT$(record$, 2)
  945.     IF RecordType$ = "S0" THEN
  946.        GOTO GetCRecord
  947.     END IF
  948.     IF RecordType$ = "S1" THEN
  949.        LOCATE 7, 1
  950.        PRINT "Transfering following S1 record."
  951.        LOCATE 8, 1
  952.        PRINT "                                                                    "
  953.        LOCATE 8, 1
  954.        PRINT MID$(record$, 5, LEN(record$) - 6)
  955.        RecordsSent = RecordsSent + 1
  956.        LOCATE 6, 15
  957.        PRINT RecordsSent
  958.        RecordLength$ = MID$(record$, 3, 2)
  959.        RecordAddress$ = MID$(record$, 5, 4)
  960.        record$ = RIGHT$(record$, LEN(record$) - 8)
  961. ParseCAndSend:
  962. SendCAddress:
  963.        TransErrorCode = 0
  964.        TransHexValue$ = LEFT$(RecordAddress$, 2)
  965.        MSB$ = LEFT$(RecordAddress$, 2)
  966.        GOSUB SENDxVALUE
  967.        VerifyFirstOnly = 1
  968.        SentValue = value
  969.        GOSUB CheckRecValue
  970.        IF TransErrorCode <> 1 THEN
  971.           LOCATE 20, 1
  972.           PRINT "Verification of MSB of address failed."
  973.           PRINT "Reset the HC11"
  974.           CLOSE
  975.           INPUT "Hit RETURN to continue."; CR$
  976.           RETURN PickMainOption
  977.        END IF
  978.        TransHexValue$ = RIGHT$(RecordAddress$, 2)
  979.        LSB$ = RIGHT$(RecordAddress$, 2)
  980.        GOSUB SENDxVALUE
  981.        VerifyFirstOnly = 1
  982.        SentValue = value
  983.        GOSUB CheckRecValue
  984.        IF TransErrorCode <> 1 THEN
  985.           LOCATE 20, 1
  986.           PRINT "Verification of LSB of address failed."
  987.           PRINT "Reset the HC11"
  988.           CLOSE
  989.           INPUT "Hit RETURN to continue."; CR$
  990.           RETURN PickMainOption
  991.        ELSE
  992.           PrintRecord$ = MSB$ + LSB$
  993.           LOCATE 10, 1
  994.           PRINT "                                                         "
  995.           LOCATE 10, 1
  996.           PRINT PrintRecord$
  997.        END IF
  998. SendCRecordLength:
  999.        TransHexValue$ = RecordLength$
  1000.        GOSUB SENDxVALUE
  1001.        VerifyFirstOnly = 1
  1002.        SentValue = value
  1003.        GOSUB CheckRecValue
  1004.        IF TransErrorCode <> 1 THEN
  1005.           LOCATE 20, 1
  1006.           PRINT "Verification of record length failed."
  1007.           PRINT "Reset the HC11"
  1008.           CLOSE
  1009.           PRINT "Hit RETURN to continue,"; CR$
  1010.           RETURN PickMainOption
  1011.        END IF
  1012. SendCData:
  1013.        IF LEN(record$) > 2 THEN
  1014.           TransHexValue$ = LEFT$(record$, 2)
  1015.           record$ = RIGHT$(record$, LEN(record$) - 2)
  1016.           GOSUB SENDxVALUE
  1017.           VerifyFirstOnly = 1
  1018.           SentValue = value
  1019.           GOSUB CheckRecValue
  1020.           GOSUB Back2Hex
  1021.           PrintRecord$ = PrintRecord$ + Byte$
  1022.           LOCATE 10, 1
  1023.           PRINT "                                                                    "
  1024.           LOCATE 10, 1
  1025.           PRINT PrintRecord$
  1026.           IF TransErrorCode <> 1 THEN
  1027.          LOCATE 14, 1
  1028.          PRINT "Verification failed."
  1029.          INPUT "Hit RETURN to continue."; CR$
  1030.          GOTO SendCData
  1031.           ELSE
  1032.          GOTO SendCData
  1033.           END IF
  1034.        ELSE
  1035.           FirstRecordSent = 1
  1036.           GOTO GetCRecord
  1037.        END IF
  1038.     END IF
  1039.     IF RecordType$ = "S9" THEN
  1040.        TransErrorCode = 0
  1041.        TransHexValue$ = "00"
  1042.        GOSUB SENDxVALUE
  1043.        VerifyFirstOnly = 1
  1044.        SentValue = value
  1045.        GOSUB CheckRecValue
  1046.        IF TransErrorCode <> 1 THEN
  1047.           LOCATE 20, 1
  1048.           PRINT "Verification of end of file1 failed."
  1049.           PRINT "Reset the HC11."
  1050.           CLOSE
  1051.           INPUT "Hit RETURN to continue."; CR$
  1052.           RETURN PickMainOption
  1053.        END IF
  1054.        TransErrorCode = 0
  1055.        TransHexValue$ = "00"
  1056.        GOSUB SENDxVALUE
  1057.        VerifyFirstOnly = 1
  1058.        SentValue = value
  1059.        GOSUB CheckRecValue
  1060.        IF TransErrorCode <> 1 THEN
  1061.           LOCATE 20, 1
  1062.           PRINT "Verification of end of file2 failed."
  1063.           PRINT "Reset the HC11."
  1064.           CLOSE
  1065.           INPUT "Hit RETURN to continue."; CR$
  1066.           RETURN PickMainOption
  1067.        END IF
  1068.        TransErrorCode = 0
  1069.        TransHexValue$ = "00"
  1070.        GOSUB SENDxVALUE
  1071.        VerifyFirstOnly = 1
  1072.        SentValue = value
  1073.        GOSUB CheckRecValue
  1074.        IF TransErrorCode <> 1 THEN
  1075.           LOCATE 20, 1
  1076.           PRINT "Verification of end of file3 failed."
  1077.           PRINT "Reset the HC11."
  1078.           CLOSE
  1079.           INPUT "Hit RETURN to continue."; CR$
  1080.           RETURN PickMainOption
  1081.        END IF
  1082.        CLOSE #1
  1083.        CLOSE #2
  1084.        RETURN
  1085.     ELSE
  1086.        LOCATE 20, 1
  1087.        PRINT "A Non S19 record has been encountered. Abort Download."
  1088.        PRINT "Reset the HC11"
  1089.        CLOSE
  1090.        INPUT "Hit RETURN to continue."; CR$
  1091.        RETURN PickMainOption
  1092.     END IF
  1093.  
  1094.  
  1095.  
  1096.  
  1097. '*****************************************************************************
  1098. '*                                                                           *
  1099. '*                                                                           *
  1100. '*  Call into this routine with parameter TransHexValue = string of two      *
  1101. '*     characters consisting of the byte in hex to be sent.                  *
  1102. '*  Routine also increments BytesSent                                        *
  1103. '*                                                                           *
  1104. '*****************************************************************************
  1105. SENDxVALUE:
  1106. TESTxCOUNT = 1
  1107. FirstByteLoop = 0
  1108. ConvertValue:
  1109. Nibble$ = LEFT$(TransHexValue$, 1)
  1110. Nibble = INSTR(HexConvert$, Nibble$) - 1
  1111. IF Nibble = -1 THEN
  1112.    CLS
  1113.    PRINT "Error converting number1 to hex."
  1114.    PRINT "Reset the HC11."
  1115.    CLOSE
  1116.    INPUT "Hit RETURN to continue."; CR$
  1117.    RETURN PickMainOption
  1118. END IF
  1119. MSBNibble = Nibble * 16
  1120. Nibble$ = RIGHT$(TransHexValue$, 1)
  1121. Nibble = INSTR(HexConvert$, Nibble$) - 1
  1122. IF Nibble = -1 THEN
  1123.    CLS
  1124.    PRINT "Error converting number2 to hex."
  1125.    PRINT "Reset the HC11."
  1126.    CLOSE
  1127.    INPUT "Hit RETURN to continue."; CR$
  1128.    RETURN PickMainOption
  1129. END IF
  1130. value = MSBNibble + Nibble
  1131. TRANSxVALUE:
  1132. PRINT #1, CHR$(value);
  1133. TransErrorCode = 1
  1134. RETURN
  1135.  
  1136.  
  1137.  
  1138. '*****************************************************************************
  1139. '*                                                                           *
  1140. '*                                                                           *
  1141. '*                     Converts Val1 back to Hex                             *
  1142. '*                                                                           *
  1143. '*                                                                           *
  1144. '*****************************************************************************
  1145.  
  1146. Back2Hex:
  1147. High = INT(VAL1 \ 16)
  1148. High$ = HEX$(High)
  1149. Low = VAL1 - (High * 16)
  1150. Low$ = HEX$(Low)
  1151. Byte$ = High$ + Low$
  1152. RETURN
  1153.  
  1154.  
  1155.  
  1156. '*****************************************************************************
  1157. '*                                                                           *
  1158. '*                                                                           *
  1159. '*             Compares rec value with variable "Value"                      *
  1160. '*                                                                           *
  1161. '*                                                                           *
  1162. '*****************************************************************************
  1163. CheckRecValue:
  1164. TESTxCOUNT = 0
  1165. TESTxLOOP1:
  1166. IF NOT EOF(1) THEN
  1167.     INP$ = INPUT$(LOC(1), #1)
  1168.     VAL1 = ASC(INP$)
  1169.     IF VAL1 = value THEN
  1170.         TransErrorCode = 1
  1171.         BytesSent = BytesSent + 1
  1172.         RETURN
  1173.     ELSE
  1174.         LOCATE 15, 1
  1175.         PRINT "Value Returned Wrong"
  1176.         PRINT "Value Sent = "; value
  1177.         PRINT "Value Received from HC11 ="; VAL1
  1178.         IF Debug = 1 THEN
  1179.            INPUT "Hit Return to End"; CR$
  1180.         END IF
  1181.         LOCATE 13, 1
  1182.         PRINT "                                    "
  1183.         PRINT "                                    "
  1184.         PRINT "                                    "
  1185.         PRINT "                                    "
  1186.         PRINT "                                    "
  1187.         PRINT "                                    "
  1188.         TransErrorCode = 0
  1189.         RETURN
  1190.     END IF
  1191. ELSE
  1192.     TESTxCOUNT = TESTxCOUNT + 1
  1193.     IF TESTxCOUNT > ResponseTime THEN
  1194.         PRINT "HC11 NOT RESPONDING TO VALUE"
  1195.         PRINT "                                    "
  1196.         PRINT "                                    "
  1197.         TransErrorCode = 0
  1198.         RETURN
  1199.     ELSE
  1200.         GOTO TESTxLOOP1
  1201.     END IF
  1202. END IF
  1203.  
  1204.  
  1205. '*****************************************************************************
  1206. '*                                                                           *
  1207. '*                                                                           *
  1208. '*               Check that all parts got boot code correctly                *
  1209. '*                                                                           *
  1210. '*                                                                           *
  1211. '*****************************************************************************
  1212.  
  1213. PollAfterBootLoad:
  1214. IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  1215. IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  1216. BoardAddress = 0
  1217. TalkAddress = 8
  1218. FOR I = 1 TO 9
  1219.   GoodBoard(I) = 1
  1220.   value = BoardAddress
  1221.   LOCATE 10, 1
  1222.   PRINT "Checking RAM download."
  1223.   LOCATE 12, 1
  1224.   PRINT "Sending board address: "; BoardAddress
  1225.   GOSUB TRANSxVALUE
  1226.   IF BoardAddress = 8 THEN GOTO NextBootPoll
  1227.   GOSUB CheckRecValue
  1228.   IF TransErrorCode <> 1 THEN
  1229.      GoodBoard(I) = 2
  1230.      GOTO NextBootPoll
  1231.   END IF
  1232.   TalkAddress = BoardAddress
  1233.   LOCATE 14, 1
  1234.   PRINT "Verifying Checksum"
  1235.   GOSUB TRANSxVALUE
  1236.   value = CheckSum
  1237.   GOSUB CheckRecValue
  1238.   IF TransErrorCode <> 1 THEN
  1239.      GoodBoard(I) = 3
  1240.      GOTO NextBootPoll
  1241.   END IF
  1242. NextBootPoll:
  1243.   BoardAddress = BoardAddress + 1
  1244. NEXT I
  1245. CLOSE #1
  1246. RETURN
  1247. '*
  1248. '*
  1249. '*
  1250. '*****************************************************************************
  1251. '*****************************************************************************
  1252. '*
  1253. '*
  1254. ErrorTrap:
  1255. CLS
  1256. PRINT "File Name does not exist."
  1257. PRINT
  1258. PRINT "Enter another file name or"
  1259. INPUT "Reset HC11 then enter RETURN to return to main menu."; Filename$
  1260. IF Filename$ = "" THEN
  1261.    RESUME PickMainOption
  1262. ELSE
  1263.    RESUME
  1264. END IF
  1265. '*
  1266. '*
  1267. '*
  1268. END
  1269. '
  1270. '
  1271. '
  1272. '
  1273. '
  1274. '***************************************************************************
  1275. '***************                                             ***************
  1276. '***************                  END ROUTINE                ***************
  1277. '***************                                             ***************
  1278. '***************************************************************************
  1279.  
  1280.  
  1281.  
  1282.